"""
Main logic file
"""


from greatwall.models import Wall
from greatwall.models import Stage
from greatwall.models import Card

class CardwallCtrl(object):

    def __init__(self):
        pass

    def get_all_walls(self):
        all_existing_walls = Wall.objects.order_by('date_created')
        return all_existing_walls

    def get_wall_by_id(self, wall_id):
        wall = Wall.objects.get(id=wall_id)
        return wall

    def get_all_active_walls(self):
        active_existing_walls = Wall.objects.filter(status='I').\
            order_by('date_created')
        return active_existing_walls

    def get_all_trash_walls(self):
        active_existing_walls = Wall.objects.filter(status='T').\
            order_by('date_created')
        return active_existing_walls

    def get_all_archived_walls(self):
        active_existing_walls = Wall.objects.filter(status='A').\
            order_by('date_created')
        return active_existing_walls

    def get_active_stages_for_wall(self, wall):
        active_stages = Stage.objects.filter(fk_wall=wall, is_active=True)
        return active_stages

    def get_all_cards_for_stage(self, stage):
        active_cards = Cards.objects.filter(fk_stage=stage, status='I')
        return active_cards
